FROM ubuntu as php8
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai
RUN apt-get update && apt-get -y dist-upgrade
RUN apt-get install -y software-properties-common \
&&  add-apt-repository ppa:apt-fast/stable \
&&  apt-get install -y  apt-fast \
&&  add-apt-repository ppa:ondrej/php  \
&&  apt-get update

RUN apt-fast -y install  php8.1 php8.1-dom  php8.1-dev   php-pear  php8.1-fpm php8.1-mysql php8.1-curl  php8.1-mbstring php8.1-xml php8.1-intl  php8.1-redis php8.1-gd php8.1-zip redis php8.1-mongodb
RUN curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer
RUN apt-fast -y  install git vim zip unzip net-tools wget
RUN apt-fast -y install libreadline-dev libpcre3-dev libssl-dev perl zlib1g-dev
RUN cd /usr/local/src \
&& wget https://openresty.org/download/openresty-1.19.9.1.tar.gz  \
&& tar xzvf openresty-1.19.9.1.tar.gz \
&& cd openresty-1.19.9.1/ \
&& ./configure && make && make install

RUN ln -s /usr/local/openresty/nginx/sbin/nginx /usr/local/sbin/nginx \
&& mkdir /usr/local/openresty/nginx/conf/sites
WORKDIR /www/workspace/
EXPOSE 80

RUN  cd ../ && wget https://github.com/swoole/swoole-src/archive/refs/tags/v4.8.12.tar.gz \
     && tar -xvf v4.8.12.tar.gz \
    && cd swoole-src-4.8.12 \
     && phpize && \
        ./configure && \
        make &&  make install
RUN sed -i "s/;extension=bz2/extension=swoole.so/g" /etc/php/8.1/cli/php.ini

CMD ["tail","-f","/dev/null"]